<!-- 课程班级 -->
<template>
	<view class="contaier">
		<u-sticky>
			<!-- 只能有一个根元素 -->
			<view class="sticky">
				<u-tabs-swiper activeColor="#0081ff" ref="tabs" :list="list" :current="current" @change="change"
					:is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
		</u-sticky>
		<mescroll-body ref="mescrollRef" safearea @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="list-content">
				<view class="cardBox" v-for="(item,index) in dataList" :key="index">
					<view class="order" @click="handleDetail(item)">
						<view class="top">

							<view class="left">
								<uni-text class="cuIcon-titles text-blue"></uni-text>
								<view @click.stop="openCompany(item)"
									:class="userinfo.roleName.indexOf('客户经理')> -1 && item.type!=2?'sitemtore undline':'sitemtore'">
									{{item.customerName.replace(item.hideName, '******')}}
								</view>

							</view>
							<view class="right">
								<text class="text-blue">{{item.typeDesc}}</text>

							</view>
						</view>
						<view class="top">

							<view class="left">
								<uni-text class="cuIcon-titles text-blue"></uni-text>
								<view class="">期望贷款金额 {{ item.needAmount }}万元</view>

							</view>

						</view>
						<view class="need-remark">需求描述：{{item.needDesc}}</view>
						<view class="bottom">
							<view>

								<text class="text-blue text-shadow">预计用款时间：{{item.needDate}}</text>
							</view>


						</view>
						<view class="bottom">
							<view>

								<text class="text-blue text-shadow">创建时间：{{item.creatorTime}}</text>
							</view>


						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>

</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import config from '@/common/js/config.js'
	export default {
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		data() {
			return {
				percent: 50,
				activeColor: '#0081ff',
				striped: false,
				stripedActive: false,

				dataList: [],
				list: [],
				current: 0,
				tabsHeight: 0,
				userinfo: {},

				dx: 0,
				loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
				needTypeData: this.$jnpf.dictionaryData('needType'),
			};
		},
		onLoad() {
			this.list = this.needTypeData.map(item => {
				return {
					name: item.label
				}
			})

			const userProvider = uni.getStorageSync(config.Global.cache + '_UserProvider');

			this.userinfo = userProvider;
			// this.getOrderList(0);
			// this.getOrderList(1);
			// this.getOrderList(3);
		},
		methods: {
			upCallback(page) {
				let httpData = {
					currentPage: page.num,
					pageSize: page.size,
					sidx: 'CreatorTime',
					type: this.current
				}
				this.$helper.ajax({
					url: `/api/Jiushi/Customerneed`,
					method: 'GET',
					data: httpData,
					success: res => {
						let curPageLen = res.data.data.list.length;
						let totalSize = res.data.data.pagination.total;
						this.mescroll.endBySize(curPageLen, totalSize);
						if (page.num == 1) {
							this.dataList = []
						}
						let tempList = res.data.data.list.map(item => {
							item.typeDesc = this.needTypeData.find(loan => loan.value == item.type)
								.label
							return item
						})
						this.dataList = this.dataList.concat(tempList);
					}
				});
			},
			openCompany(detail) {
				const userProvider = uni.getStorageSync(config.Global.cache + '_UserProvider');;
				if (userProvider.roleName.indexOf('客户经理') > -1 && detail.type != 2) {
					let url = '../../customer/customer?id=' + detail.customerId
					uni.navigateTo({
						url: url
					})
				}

			},
			handleDetail(detail) {
				const userProvider = uni.getStorageSync(config.Global.cache + '_UserProvider');;
				if (userProvider.roleName.indexOf('客户经理') > -1 && detail.type != 2) {
					let url = '../subpage/demanddetailinfo?id=' + detail.id
					uni.navigateTo({
						url: url
					})
				}

			},
			// tab栏切换
			change(index) {
				this.current = index;
				this.mescroll.resetUpScroll();
				this.mescroll.scrollTo(0, 200);
			}
		}
	};
</script>

<style lang="scss" scoped>
	/* #ifndef H5 */
	page {
		height: 100%;
		background-color: #f2f2f2;
	}

	/* #endif */
</style>

<style lang="scss" scoped>
	.undline {
		text-decoration: underline;

	}

	.order {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;

		.top {
			display: flex;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;

				.store {
					margin-right: 10rpx;
					font-size: 34rpx;
					font-weight: bold;
				}
			}

			.right {
				color: $u-type-warning-dark;

				.progressBox {
					width: 150rpx;
					float: right;
				}
			}
		}

		.need-remark {
			color: #666;
			font-size: 28rpx;
		}

		.item {
			display: flex;
			margin: 20rpx 0 0;

			.left {
				margin-right: 20rpx;

				image {
					width: 260rpx;
					height: 190rpx;
					border-radius: 10rpx;
				}
			}

			.content {
				margin-left: 10rpx;

				.title {
					font-size: 28rpx;
					line-height: 45rpx;
				}

				.type {
					margin: 6rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 3;
					line-clamp: 3;
					-webkit-box-orient: vertical;
				}

				.delivery-time {
					color: #0081ff;
					font-size: 24rpx;
				}
			}

			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;

				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}

				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}

		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;

			.total-price {
				font-size: 32rpx;
			}
		}

		.bottom {
			line-height: 70rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.btnBox {
				width: 150rpx;
				display: flex;
				justify-content: space-between;

				.btn {
					line-height: 52rpx;
					width: 140rpx;
					border-radius: 12rpx;
					border: 2rpx solid $u-tips-color;
					font-size: 26rpx;
					text-align: center;
					color: $u-tips-color;
				}

				.evaluate {
					color: $u-type-primary;
					border-color: $u-type-primary;
				}
			}
		}
	}

	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;

		image {
			width: 300rpx;
			border-radius: 50%;
			margin: 0 auto;
		}

		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}

		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, #1cbbb4 0%, #0081ff 100%);
		}
	}

	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
		background: #f1f1f1;
	}

	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}
</style>